using System;
using System.Collections.Generic;
using Illinois.Core.Interfaces;
using Illinois.Core.Models;

namespace Illinois.Core.Services
{
  public class BurnDownService : IBurnDownService
  {
    private readonly IBurnDownRepository _repository;

    public BurnDownService(IBurnDownRepository repository)
    {
      _repository = repository;
    }

    public int Add(string title, DateTime start, DateTime end, int initialStoryPoints, int projectId)
    {
      var burnDown = new BurnDown(title, start, end, initialStoryPoints, projectId);
      return _repository.Save(burnDown);
    }

    public int Delete(int burnDownId)
    {
      return _repository.Delete(burnDownId);
    }

    public IBurnDown GetById(int burnDownId)
    {
      return _repository.GetById(burnDownId);
    }

    public IList<IBurnDown> GetAll(int projectId)
    {
      return _repository.GetAll(projectId);
    }

    public int SaveStoryPoints(int burnDownId, int order, int id, int points)
    {
      return _repository.SaveStoryPoints(burnDownId, new StoryPoints { Id = id, Order = order, Value = points });
    }

    public int Edit(int burnDownId, string title, int points)
    {
      return _repository.UpdateMetaData(burnDownId, title, points);
    }
  }
}
